/*
 * Copyright (c) 2018-2999 深圳市阿毛科技有限公司 All rights reserved.
 *
 * https://www.lamyz.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.lam.mall.api.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lam.common.base.controller.BaseController;
import com.lam.common.base.domain.Result;
import com.lam.common.context.TokenUtils;
import com.lam.framework.operLog.annotation.Log;
import com.lam.mall.app.vo.ProductSimpleVo;
import com.lam.mall.service.ProductService;
import com.lam.mall.service.UserProdBrowseService;
/**
 */
@RestController
@RequestMapping("/${frontPath}/user/browse")
@Log(title = "用户足迹")
public class UserBrowseApiController extends BaseController{

	@Autowired
    private UserProdBrowseService userProdBrowseService;
	@Autowired
    private ProductService productService;

    /**
     * 查询用户收藏商品数量
     */
    @GetMapping("count")
    @Log(oper = "用户浏览商品数量")
    public Result queryUserBrowseCount() {
    	
        return Result.ok(userProdBrowseService.selectCount(TokenUtils.getLoginUserid()));
    }

    @GetMapping("/prods")
    @Log(oper = "用户浏览商品列表")
    public Result prodList() {
        String userId = TokenUtils.getLoginUserid();
        startPage();
        List<ProductSimpleVo> list = productService.browseProds(userId);
        return Result.ok(getTableData(list));
    }

}
